package com.dormitory.Servlet;

import com.alibaba.fastjson.JSONObject;
import com.dormitory.dao.selectInformation;
import com.dormitory.entity.vo;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.List;
import com.dormitory.dao.*;

@WebServlet("/fudaoStudent")
public class fudaoStudent extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
        selectInformation selectInformation = new selectInformation();
        UserConnectimpl userConnectimpl = new UserConnectimpl();
        String name="潘婷";
        try {
            List<Object> list = null;
            try {
                list = selectInformation.getStudent("select * from student where 辅导员=" + "'" + name+"'");
            } catch (SQLException e) {
                e.printStackTrace();
            }
            resp.setContentType("text/html;charset=utf-8");
            vo v = new vo();
            v.setCode(0);
            v.setMsg("success");
            v.setCount(list.size());
            v.setData(list);
            resp.getWriter().write(JSONObject.toJSON(v).toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
